package com.itheima.mapper;


import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpExpr;
import com.itheima.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.servlet.DispatcherServlet;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {

    /**  接口中的方法而已
     * @version 1.0
     * 返回统计所有数据的总数
     * @return
     */
//    @Select("select count(1)  from emp e left join dept d on e.dept_id = d.id;")
//    public Long count();
    /**
     * 分页查询员工数据
     * @param start
     * @param pageSize
     * @return
     */
//    @Select("select *,d.name as deptName from emp e left join dept d on e.dept_id = d.id " +
//            "order by e.update_time desc limit #{start},#{pageSize};")
//    public List<Emp> list(Integer start, Integer pageSize);

    /**
     * 查询所有员工数据 PagesHelper
     * @return
     */
//    @Select("select e.*, d.name deptName from emp as e left join dept as d on e.dept_id = d.id\n" +
//            "        where e.name like %#{name}%\n" +
//            "          and e.gender = #{gender}\n" +
//            "          and e.entry_date between #{begin} and #{end}")
//            此时已经报错near '%'李'% Parameter index out of range (4 > number of parameters, which is 3).
    //就算将%#{name}%改为--》concat('%',#{name},'%')，此时如果少传一个参数则会返回空数组






//    @Select("select e.*, d.name deptName from emp as e left join dept as d on e.dept_id = d.id\n" +
//            "        where e.name like concat('%',#{name},'%')\n" +
//            "        and e.gender = #{gender}\n" +
//            "        and e.entry_date between #{begin} and #{end}")
    public List<Emp> list(EmpQueryParam empQueryParam);

    void insert(Emp emp);


    void deleteByIds(List<Integer> ids);

    Emp getById(Integer id);

    void updateById(Emp emp);

    @MapKey("pos")
    List<Map<String, Object>> countEmpJobData();

    @MapKey("name")
    List<Map> countEmpGenderData();

    @Select("select * from emp")
    List<Emp> findAll();

    @Select("select id,username,name from emp where username=#{username} and password=#{password}")
    Emp getByUsernameAndPassword(Emp emp);
}
